import { observable, action } from 'mobx';
import { WeaForm, WeaTableNew } from 'comsMobx';
import * as Api from '../../apis/docWorkflowApi/recPostDocUnitApi';

const { TableStore } = WeaTableNew;

class RecPostDocUnitStore {
  @observable form = new WeaForm();
  @observable tableStore = new TableStore();
  @observable receiveUnitId = '40';


  @action.bound
  getCondition() {
    const params = {
      receiveUnitId: this.receiveUnitId,
    };
    Api.getCondition(params).then((data) => {
      if (data.api_status) {
        if (data.sessionkey) {
          this.tableStore.getDatas(data.sessionkey, '', 10, 10);
        }
        this.form.setCondition(data.groupsCondition);
      }
    });
  }

  @action.bound
  setReceiveUnitId(receiveUnitId) {
    this.receiveUnitId = receiveUnitId;
  }
}
export default RecPostDocUnitStore;
